{% extends "base.html" %}
{% block title %}书籍详情{% endblock %}
{% block content %}
<h2>书籍详情</h2>
<ul>
    <li>书名: {{ book.name }}</li>
    <li>作者: {{ book.author }}</li>
    <li>价格: {{ book.price }}</li>
</ul>
<br>
{% if borrow_book %}
<span>
    您当前已经借阅了这本书，到期时间为{{ borrow_book.return_time }}，

    {% if borrow_book.is_overdue %}
    借阅已过期，请尽快归还
    {% else %}
    如果即将到期，点击借阅，将自动为您续借7天
    {% endif %}
</span>
{% endif %}
<form method="POST" action="{{ url_for('user_borrow.post_borrow') }}">
    {{ borrow_form.hidden_tag() }}
    <p>
        <input type="hidden" name="book_id" value="{{ book.id }}">
        {% for error in borrow_form.book_id.errors %}
            <span style="color: red;">[{{ error }}]</span>
        {% endfor %}
    </p>
    <p>{{ borrow_form.submit() }}</p>
</form>
{% if borrow_book %}
<form method="POST" action="{{ url_for('user_return.post_return') }}">
    {{ return_form.hidden_tag() }}
    <p>
        <input type="hidden" name="borrow_book_id" value="{{ borrow_book.id }}">
        {% for error in return_form.borrow_book_id.errors %}
            <span style="color: red;">[{{ error }}]</span>
        {% endfor %}
    </p>
    <p>{{ return_form.submit() }}</p>
</form>
{% endif %}
<a href="{{ url_for('user_borrow.book_list') }}">返回书籍列表</a>
{% endblock %}
